#!/usr/bin/ruby
# SPDX-License-Identifier: MulanPSL-2.0+
# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
# frozen_string_literal: true

require 'sinatra'

require_relative '../../src/reproducible-test/reproducible_api.rb'

set :bind, '0.0.0.0'
set :port, 10006
set :show_exceptions, false
set :environment, :production

# POST /reproducible/diff_2rpms
# - header: "Content-Type: Application/json"
# - body: json
#   eg:
#     {
#       "first_id": "z9.14162556",
#       "second_id": "z9.14164068",
#     }
post '/reproducible/diff_2rpms' do
  request.body.rewind # in case someone already read it
  diff_rpms(request.body.read)
end
